Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Project Express API #528

Open
wants to merge 27 commits into
base: master
Choose a base branch
from
Open

Project Express API #528

wants to merge 27 commits into from

Conversation

joheri1
Copy link

@joheri1 joheri1 commented Dec 7, 2024

Copy link
Contributor

@HIPPIEKICK HIPPIEKICK left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job Johanna! Just remember going forward to make use of query params instead of creating different endpoints to filter.

Comment on lines +35 to +39
app.get("/elves/all", (request, response) => {

// Return all elves
response.json(elves);
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hehe love the dataset! A more RESTful approach would be to name this endpoint just /elves and then have different query params to use as filters, e.g.
/elves?top-twelves=true
/elves?title=backend dasher

Comment on lines +86 to +89
app.get("/test", (request, response) => {
response.send("Jingle bells, the server tells, it's up and running well!");
console.log("Jingle bells, the server tells, it's up and running well!");
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😆 ⭐

Comment on lines +71 to +80
app.get("/elves/:id", (request, response) => {
const id = request.params.id;

const elf = elves.find((record) => record.elfID === +id);
if (elf) {
response.status(200).json(elf);
} else {
response.status(404).send("404 - No elf found with that ID");
}
})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice error handling

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants